<?php
// app/Controller/AppController.php
class AppController extends Controller {

	//Carga de Ayudantes o Helpers
	var $helpers = array(
		'Html',
        'Form',
        'Javascript',
        'Ajax',
        'Session',
	);

	//Componentes de los Controladores
    public $components = array(
        'Session',
        'Auth' => array(
        	'loginAction' => array('controller' => 'usuarios', 'action' => 'login'),
            'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
            'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
            'authError' => 'Did you really think you are allowed to see that?',
//            'authenticate' => array(
//	            'Form' => array(
//	                'fields' => array('username' => 'login', 'password' => 'password')
//	            )
//	        ),

        ),
        'RequestHandler',
        'Email',
    );

	//Aca se cargan los modelos a utilizar en un Controlador que se heredan en cada uno
	var $uses = array(

	);

	//Este metodo carga ante cada peticion de ajax el layout correspondiente de ajax.
	function beforeRender(){
        if( $this->RequestHandler->isAjax() ) {
            $this->layout = 'ajax';
            $this->autoRender = false;
            Configure::write('debug', 0);
        }

		if( $this->RequestHandler->isMobile() ) {
            preg_match('/' . REQUEST_MOBILE_UA . '/i', $_SERVER['HTTP_USER_AGENT'], $match);
		  if (!empty($match)) {
		    //echo pr($_SERVER['HTTP_USER_AGENT']);
		  }
		  return false;
        }

		//pr($this->RequestHandler->getClientIP(). ' ' .$this->RequestHandler->getReferer());
    }


    function beforeFilter() {
    	parent::beforeFilter();
        //$this->Auth->allow('*');
    }

}